﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProfilesManager.ascx.cs" Inherits="Controls_Admin_ProfilesManager" %>
<asp:UpdatePanel ID="upProfiles" runat="server">
<ContentTemplate>
	<UI:GridViewEx ID="grvProfiles" DataSourceID="dsProfiles" runat="server" AutoGenerateColumns="false"
		AllowEdit="true" ShowSearch="true" ShowHeader="true" AllowSorting="true" GridViewUpdate="false"
		CellPadding="2" CellSpacing="1" GridLines="None" DataKeyNames="ID">
		<Columns>
			<asp:BoundField DataField="UserName" HeaderText="Profile" SortExpression="UserName" />
			<asp:BoundField DataField="FilterLast" HeaderText="Last Filter" SortExpression="FilterLast" />
		</Columns>
	</UI:GridViewEx>
	<hr />
	<b style="margin-left:15px"> User Name:</b><asp:TextBox ID="tbNewUser" runat="server" />
	<asp:Button ID="btnNewProfile" Style="overflow: visible" runat="server" Text="Create Profile" />
	<asp:Button ID="btnRefreshSchema" Style="overflow: visible" runat="server" Text="Refresh Schema" />
	<asp:Button ID="btnCopyToUserSettings" Style="overflow: visible" runat="server" Text="Copy To UserSetings" />
	<table Width="100%" cellpadding="0" CellSpacing="0"><tr><td Width="20%"><hr /></td><td nowrap style="padding:0px 10px"><b>Filters</b></td><td Width="80%"><hr /></td></tr></table>
	<UI:GridViewEx id="grvFilters" DataSourceID="dsFilters" runat="server" ShowHeader="false" AllowEdit="false" AutoGenerateColumns="false"
			DataKeyNames="Name">
		<Columns>
		<asp:BoundField DataField="Name" />
		<asp:TemplateField>
			<ItemTemplate>
				<asp:DropDownList ID="ddlUserTo" onclick="event.cancelBubble=true;" DataSourceID="dsUsers" DataTextField="Nick" DataValueField="UserName" runat="server" AppendDataBoundItems="true"><asp:ListItem Text="Select Profile ..." Value=""></asp:ListItem></asp:DropDownList>
			</ItemTemplate>
		</asp:TemplateField>
		<asp:ButtonField CommandName="Copy" Text="Copy" />
		<asp:BoundField DataField="Value" />
		</Columns>
	</UI:GridViewEx>
<DS:ProfileFilterGroupsDataSource ID="dsPFG" runat="server">
<SelectParameters>
	<asp:ControlParameter	 ControlID="grvProfiles" PropertyName="SelectedValue" Name="UserName" />
	<asp:ControlParameter	 ControlID="grvFilters" PropertyName="SelectedValue" Name="FilterName" />
</SelectParameters>
<DeleteParameters>
	<asp:ControlParameter	 ControlID="grvProfiles" PropertyName="SelectedValue" Name="UserName" />
</DeleteParameters>
</DS:ProfileFilterGroupsDataSource>
<UI:GridViewEx DataSourceID="dsPFG" runat="server" AutoGenerateColumns="false"
	ShowFooter="true" ShowSearch="false" AllowSorting="true" AllowEdit="false"
	DataKeyNames="FilterName,GroupName" OnRowInserting="grvPFG_RowInserting"
>
<Columns>
<asp:TemplateField HeaderText="Group" SortExpression="GroupName">
<ItemTemplate><%#Eval("GroupName")%></ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="GroupName" DataSourceID="dsGroups" DataTextField="principal_id" DataValueField="principal_id" runat="server" onclick="event.cancelBubble=true"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</UI:GridViewEx>

</ContentTemplate></asp:UpdatePanel>
<!-- DataSources -->
<DS:ProfilesDataSource ID="dsProfiles" runat="server" UpdateMethod="Update" />
<DS:ObjectDataSourceBase ID="dsFilters" runat="server">
<SelectParameters>
	<asp:ControlParameter	 ControlID="grvProfiles" PropertyName="SelectedValue" Name="Username" />
</SelectParameters>
<DeleteParameters>
	<asp:ControlParameter	 ControlID="grvProfiles" PropertyName="SelectedValue" Name="Username" />
</DeleteParameters>
</DS:ObjectDataSourceBase>
<DS:UsersDataSource ID="dsUsers" ShowProfiles="true" runat="server" />
<DS:GroupsDataSource ID="dsGroups" runat="server" />